<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单类型">
              <j-dict-select-tag placeholder="请选择类型" v-model="queryParam.remark8" dictCode="spmplb"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="订单号" v-model="queryParam.orderNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="昵称">
              <a-input placeholder="请输入电话号" v-model="queryParam.wxName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="收货人电话">
              <a-input placeholder="请输入电话号" v-model="queryParam.remark3"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="收货人">
              <a-input placeholder="请输入真实姓名" v-model="queryParam.remark2"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <!--<div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单管理')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>-->

    <!-- table区域-begin -->
    <div>
      <!--<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a v-if="record.remark8 == 0" @click="handleEdit(record)">编辑</a>
          <a v-else="record.remark8 == 1"></a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <vOrder-modal ref="modalForm" @ok="modalFormOk"></vOrder-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import VOrderModal from './modules/VOrderModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: "VOrderList",
    mixins:[JeecgListMixin],
    components: {
      VOrderModal
    },
    data () {
      return {
        description: '订单管理页面',
        queryParam: {
          orderNumber: '',
          remark8: '',
        },
        dictOptions:{
          spmplb:[],
          fhzt: [],
        },
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '订单号',
            align:"center",
            dataIndex: 'orderNumber'
          },
          {
            title:'订单类型',
            align:"center",
            dataIndex: 'remark8',
            customRender:(text)=>{
              debugger
              if(!text){
                return ''
              }else{
                return filterMultiDictText(this.dictOptions['spmplb'], text+"")
              }
            }
          },
          {
            title: '商品名称',
            align:"center",
            dataIndex: 'title'
          },
          {
            title: '兑换数量',
            align:"center",
            dataIndex: 'remark9'
          },
          {
            title: '商品单价',
            align:"center",
            dataIndex: 'remark10'
          },
          {
            title: '订单金额',
            align:"center",
            dataIndex: 'price'
          },
		      {
            title: '微信昵称',
            align:"center",
            dataIndex: 'wxName'
           },
		      {
            title: '电话号',
            align:"center",
            dataIndex: 'phone'
           },
          {
            title: '兑换时间',
            align:"center",
            dataIndex: 'orderTime'
          },
		      {
            title: '收货人',
            align:"center",
            dataIndex: 'remark2'
           },
          {
            title: '收货人电话',
            align:"center",
            dataIndex: 'remark3'
          },
          {
            title: '收货地址',
            align:"center",
            dataIndex: 'remark4'
           },
          {
            title:'发货状态',
            align:"center",
            dataIndex: 'remark5',
            customRender:(text)=>{
              if(!text){
                return ''
              }else{
                return filterMultiDictText(this.dictOptions['fhzt'], text+"")
              }
            }
          },
          {
            title: '快递公司',
            align:"center",
            dataIndex: 'remark6'
          },
          {
            title: '快递单号',
            align:"center",
            dataIndex: 'remark7'
          },
		    /*{
            title: '平台推广等级',
            align:"center",
            dataIndex: 'rank'
           },
		      {
            title: '不知道能不能用上',
            align:"center",
            dataIndex: 'nameId'
           },*/
		     /*{
            title: 'userId',
            align:"center",
            dataIndex: 'userId'
           },*/



		   /*{
            title: '订单状态：0:未完成 1：已完成',
            align:"center",
            dataIndex: 'orderStatue'
           },*/

		  /* {
            title: '账单类型  0:支付,1:奖励金提现,2:推广提现',
            align:"center",
            dataIndex: 'type'
           },*/
		   /*{
            title: '0:正常,1:删除',
            align:"center",
            dataIndex: 'delflag'
           },
		   {
            title: 'remark',
            align:"center",
            dataIndex: 'remark'
           },
		   {
            title: '手续费',
            align:"center",
            dataIndex: 'remark1'
           },
		   {
            title: 'remark2',
            align:"center",
            dataIndex: 'remark2'
           },
		   {
            title: 'remark3',
            align:"center",
            dataIndex: 'remark3'
           },
		   {
            title: 'remark4',
            align:"center",
            dataIndex: 'remark4'
           },
		   {
            title: 'remark5',
            align:"center",
            dataIndex: 'remark5'
           },
		   {
            title: 'remark6',
            align:"center",
            dataIndex: 'remark6'
           },
		   {
            title: 'remark7',
            align:"center",
            dataIndex: 'remark7'
           },
		   {
            title: 'remark8',
            align:"center",
            dataIndex: 'remark8'
           },
		   {
            title: 'remark9',
            align:"center",
            dataIndex: 'remark9'
           },
		   {
            title: 'remark10',
            align:"center",
            dataIndex: 'remark10'
           },*/
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],

        url: {
              list: "/vorder/vOrder/list",
              delete: "/vorder/vOrder/delete",
              deleteBatch: "/vorder/vOrder/deleteBatch",
              exportXlsUrl: "vorder/vOrder/exportXls",
              importExcelUrl: "vorder/vOrder/importExcel",
           },
        }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      initDictConfig(){
        initDictOptions('spmplb').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'spmplb', res.result)
          }
        })

        initDictOptions('fhzt').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'fhzt', res.result)
          }
        })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>